<?php
namespace Home\Controller;

use Think\Controller;
/**
 * @name 前端入口controller
 * @author perry
 * @version 1.0 2015-07-30
 */
class ImageH5Controller extends Controller {

    public function index(){
        $this->display();
    }
    public function cupload(){
       try{
           $upload = new \Think\Upload();// 实例化上传类
           $upload->maxSize   =  1457280 ;// 设置附件上传大小
           $upload->exts =  array( 'jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
           $upload->rootPath = './Uploads/'; // 设置附件上传根目
           //子目录创建方式
           $upload->subName = 'nail_photos';

           // 上传文件
//           dump($upload);
           $re= $upload->upload();
           $err= $upload->getError();
           if($err){
            throw new \Exception($err, -1);
           }
           $info['savename']=$re['imagefile']['savename'];
           $info['msg']='';
       }catch (\Exception $ecx){
           $info['savename']=$ecx->getCode();
           $info['msg']=$ecx->getMessage();
       }

        $this->ajaxReturn($info);
    }

//    public function aa(){
//        try{
//            $id=1;
//            if(ic_isPosInt($id)){
//                $map['id']=$id;
//            }
//            $aa=I('aa');
//            if(ic_isPosInt($aa)){
//                $map['aa']=$aa;
//            }
//            M('aa')->where(array('id'=>$id))->save($map);
//
////            dump($aa);
//            $data['status'] = 1;
//            $data['info'] = 'ok';
//            $this->ajaxReturn($data);
//        }catch (\exception $exc){
//            $data['status'] = 400;
//            $data['info'] = $exc->getMessage();
//            $this->ajaxReturn($data);
//        }
//
//    }

}